<?php 
include_once('connection/connection.php');
include('config.php');
//session_start();
//ob_start();
include('header.php');
include('menu.php');
$frm=trim($_SESSION['formId']);
//echo $loc_id = $_SESSION['loc_id'];
$sqlGetFormDetails="select * from tbl_dtls_critical where form_id='".$frm."'";
$queryFormDetails=mysql_query($sqlGetFormDetails);
$rowCritical=mysql_fetch_array($queryFormDetails);
$id1=$rowCritical['id'];
?>
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link href="css/style_question.css" type="text/css" rel="stylesheet" />
<script language="javascript" type="text/javascript" src="js/validate.js"></script>
<title>Critical form</title>
</head>
<body>
<?php
if(isset($_POST['submit']))
{
		$fclick = true;
		$loc_id = $_SESSION['loc_id'];
		$avg_rain=$_POST['avg_rain'];
		$ancient_pond=$_POST['ancient_pond'];
		$drainage=$_POST['drainage'];
		$water_level=$_POST['water_level'];
		$hp_total=$_POST['hp_total'];
		$hp_potable=$_POST['hp_potable'];
		$hp_yield=$_POST['hp_yield'];
		$tw_total=$_POST['tw_total'];
		$tw_potable=$_POST['tw_potable'];
		$tw_yield=$_POST['tw_yield'];
		$private_no=$_POST['private_no'];
		$private_area=$_POST['private_area'];
		$govt_no=$_POST['govt_no'];
		$govt_area=$_POST['govt_area'];
		$remark=$_POST['remark'];
		
		$qr1="UPDATE tbl_dtls_critical SET avg_rain='$avg_rain', pond='$ancient_pond', drainage='$drainage', water_level='$water_level', hp_total='$hp_total', hp_potable='$hp_potable', hp_yield='$hp_yield', tw_total='$tw_total', tw_potable='$tw_potable', tw_yield='$tw_yield', pvt_no='$private_no', pvt_area='$private_area', govt_no='$govt_no', govt_area='$govt_area', remark='$remark', status='1' WHERE id='$id1'";	
		//echo $qr1;
			$result1=mysql_query($qr1);
			if($result1)
			{
				$relocatePage=true;
			}
			else 
			{
				$errorIns="Error inserting critical table <br>";
			}
			
			$qryHistory="SELECT usertype FROM tbl_dtls_createuser WHERE loginid='$loginid'";
			//echo $q;
			$recHistory=mysql_query($qryHistory);
			$rowHistory=mysql_fetch_array($recHistory);
			$user_type=$rowHistory['usertype'];
			$user_id=$_SESSION['loginid'];
			$form_id=$_SESSION['form_id'];
			$user_name=$_SESSION['name'];
			//$user_type=$_SESSION['usertype'];
			$ip=$_SERVER['REMOTE_ADDR'];
			$qryIns="INSERT INTO tbl_dtls_edit_history(user_id, form_id, action_id, ip_address, modify_date, user_type, user_name) VALUES ('$user_id', '$form_id', '9', '$ip', NOW(), '$user_type', '$user_name')";
			//echo $q5;
			$recIns=mysql_query($qryIns);	
			if($recIns)
			{
				//header('Location: critical_form2.php');
				$relocatePage=true;
				//echo "success 1";		
			}
			else 
			{
				$errorIns="Error inserting tbl_dtls_edit_history table <br>";
			}
			
			if($errorIns==0) 
			{
				echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully update this Form.</span>';
				exit();
			}
			else 
			{
				echo $errorIns;exit;
			}
			/*if($relocatePage)
			{
			echo'<span class="successmssg"><b>Congratulation!!</b><br/>You have successfully filled this Form.</span>';
				echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>'; echo'</br>';echo'</br>'; echo'</br>';
				echo '<span class="successmssg">For filling another form click here <a href="critical_form1.php">Critical Village</a></span>';
				exit();
			}
			else
			{
				echo $errorIns;exit();
			}*/
				
}
else
{
	$fclick = false;
	$flag=0;
}
?>
<div align="center">
<form action="" method="post" enctype="multipart/form-data" name="critical_form2" id="critical_form2">
	<table border="0" width="800" id="table1" cellspacing="0" cellpadding="0">
		<tr>
			<td height="30" align="center">
				<font face="Verdana" style="font-size: 10pt; font-weight: 700" color="#000000">
				Critical Village Form</font></td>
		</tr>
		<tr>
			<td align="center"><font face="Arial" style="font-size: 8.5pt" color="#000000">Page 2</font></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td bgcolor="#EEEEEE" height="22"><font color="#000000">&nbsp;
				<span style="font-weight: 700">
				<font face="Arial" style="font-size: 8.5pt"></font></span></font></td>
		</tr>
		<tr>
		  <td><table width="800" height="458" border="0" cellpadding="0" cellspacing="1" bgcolor="#FDF9EE" id="table9">
            <tr>
              <td colspan="3"><span style="font-size: 4pt">&nbsp;</span> </td>
            </tr>
            <tr>
              <td height="23" colspan=""><font face="Verdana" style="font-size: 8.5pt" color="#000000">&nbsp; 
                Average Rain Fall (mm)</font></td>
              <td width="529" colspan="3"><input type="text" name="avg_rain" id="avg_rain" class="txt" onBlur="float2dec(this)" value="<?php echo $rowCritical['avg_rain'];?>"></td>
            </tr>
            <tr>
              <td height="24" colspan="">&nbsp; <font style="font-size: 8.5pt" face="Verdana" color="#000000">Ancient Pond Existing Nos.</font></td>
              <td width="529" colspan="3"><input type="text" name="ancient_pond" id="ancient_pond" class="txt" onBlur="numeric(this)" value="<?php echo $rowCritical['pond'];?>"></td>
            </tr>
            <tr>
              <td height="23" colspan=""><font style="font-size: 8.5pt" face="Verdana" color="#000000">&nbsp;&nbsp;Drainage System and Reuse of Waste Water              </font></td>
			  <td width="529" colspan="3"><font style="font-size: 8.5pt" face="Verdana" color="#000000">
						<input type="radio" name="drainage" id="drainage" value="YES"<?php echo ($rowCritical['drainage']=='YES')?'checked':'';?>>Yes&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="radio" name="drainage" id="drainage" value="NO"<?php echo ($rowCritical['drainage']=='NO')?'checked':'';?>>No&nbsp;&nbsp;&nbsp;&nbsp;
			  <input type="radio" name="drainage" id="drainage" value="NA"<?php echo ($rowCritical['drainage']=='NA')?'checked':'';?>>Not Applicable</font></td>
			</tr>
            <tr>
              <td height="23" colspan="">&nbsp;&nbsp;<font style="font-size: 8.5pt" face="Verdana" color="#000000">Water Level Fluctuation(m)</font></td>
			  <td width="529" colspan="3"><input type="text" name="water_level" id="water_level" class="txt" onBlur="float2dec(this)" value="<?php echo $rowCritical['water_level'];?>"></td>
            </tr>
			<tr>
              <td colspan="3">&nbsp;</td>
            </tr>
            <tr>
              <td colspan="4" bgcolor="eeeeee" height="22">&nbsp;<font face="Verdana" color="#000000" style="font-size: 8.5pt"><b>Status of Water Source</b></font></td>
            </tr>
            <tr>
              <td colspan="4"><table border="0" width="800" cellspacing="0">
                  <tr>
                    <td align="center" height="28" bgcolor="#F7E6B7" width="27%"><font style="font-size: 8.5pt" face="Verdana" color="#000000">Source Type (Functional & Repairable only)</font></td>
                    <td width="23%" height="28" align="center" bgcolor="#F7E6B7"><font style="font-size: 8.5pt" face="Verdana" color="#000000"> Total Nos.</font></td>
                    <td width="27%" align="center" bgcolor="#F7E6B7"><font style="font-size: 8.5pt" face="Verdana" color="#000000"> Potable Nos.</font></td>
                    <td width="23%" align="center" bgcolor="#F7E6B7"><font style="font-size: 8.5pt" face="Verdana" color="#000000">Average Yield</font></td>
                  <tr align="center">
                    <td width="27%" height="29"><font style="font-size: 8.5pt" face="Verdana" color="#000000">HP</font></td>
                    <td><input type="text" name="hp_total" id="hp_total" size="18" class="txt5" onBlur="numeric(this)" value="<?php echo $rowCritical['hp_total'];?>"></td>
                    <td><input type="text" name="hp_potable" id="hp_potable" size="18" class="txt5" onBlur="numeric(this);total_pot_hp()" value="<?php echo $rowCritical['hp_potable'];?>"></td>
                    <td><input type="text" name="hp_yield" id="hp_yield" size="18" class="txt5" value="10" onBlur="numeric(this)" readonly><font style="font-size: 8.5pt" face="Verdana" color="#000000">KLD</font></td>
                  </tr>
                  <tr align="center">
                    <td width="27%" height="30"><font style="font-size: 8.5pt" face="Verdana" color="#000000">TW</font></td>
                    <td><input type="text" name="tw_total" id="tw_total" size="18" class="txt5" onBlur="numeric(this)" value="<?php echo $rowCritical['tw_total'];?>"></td>
                    <td><input type="text" name="tw_potable" id="tw_potable" size="18" class="txt5" onBlur="numeric(this);total_pot_tw()" value="<?php echo $rowCritical['tw_potable'];?>"></td>
                    <td><input type="text" name="tw_yield" id="tw_yield" size="18" class="txt5" onBlur="numeric(this)" value="<?php echo $rowCritical['tw_yield'];?>"><font style="font-size: 8.5pt" face="Verdana" color="#000000">KLH</font></td>
                  </tr>
				  
              </table></td>
            </tr>
            <tr>
              <td colspan="4"  height="25">&nbsp;</td>
            </tr>
            <tr>
              <td height="106" colspan="4"><table border="0" width="800" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="22" colspan="3" bgcolor="#EEEEEE">&nbsp;<font face="Verdana" color="#000000" style="font-size: 8.5pt"><b>Pucca Roof Top</b></font></td>
                  </tr>
                <tr>
                  <td width="202" align="center" height="23" bgcolor="#F7E6B7"><font style="font-size: 8.5pt" face="Verdana" color="#000000"> Type</font></td>
                  <td align="center" width="173" height="23" bgcolor="#F7E6B7"><font style="font-size: 8.5pt" face="Verdana" color="#000000">No.</font></td>
                  <td align="center" width="375" height="23" bgcolor="#F7E6B7"><font style="font-size: 8.5pt" face="Verdana" color="#000000">Area (m2)</font></td>
                </tr>
                <tr>
                  <td width="202" height="29" align="center"><font style="font-size: 8.5pt" face="Verdana" color="#000000">&nbsp;Private Building</font> </td>
                  <td align="center" width="173"><input type="text" name="private_no" id="private_no" size="18" class="txt5" onBlur="numeric(this)" value="<?php echo $rowCritical['pvt_no'];?>">                   </td>
                 <td align="center" width="375"><input type="text" name="private_area" id="private_area" size="18" class="txt5" onBlur="float2dec(this)" value="<?php echo $rowCritical['pvt_area'];?>"></td>
                </tr>	
                <tr>
                  <td width="202" height="27" align="center"><font style="font-size: 8.5pt" face="Verdana" color="#000000">&nbsp;Govt. / Public Building</font>                  </td>
                  <td align="center" width="173"><input type="text" name="govt_no" id="govt_no" size="18" class="txt5" onBlur="numeric(this)" value="<?php echo $rowCritical['govt_no'];?>"></td>
                  <td align="center" width="375"><input type="text" name="govt_area" id="govt_area" size="18" class="txt5" onBlur="float2dec(this)" value="<?php echo $rowCritical['govt_area'];?>">                  </td>
                </tr>
              </table></td></tr>
			  <tr><td colspan="4"><hr color="#FFFFFF"></td></tr>
            <tr>
             <td width="270" height="86" colspan=""><font style="font-size: 8.5pt" face="Verdana" color="#000000">&nbsp;Remarks (If any)</font></td>
              <td colspan="3"><br><textarea name="remark" id="remark" rows="4" cols="40">
			  <?php echo $rowCritical['remark'];?>
			  </textarea></td>
            </tr>
          </table></td></tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>
			<p align="center">
			<input type="submit" value="Submit" name="submit" style="font-size: 8pt; font-family: Verdana; border-style: solid; border-width: 3px; border-color:#F7E6B7">&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		</table>
</form>		
</div>
</body>
</html>